package com.ttg.web.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.common.enums.OrgStatusEnum;
import com.ttg.model.mapper.OrganMapper;
import com.ttg.model.pojo.Organ;
import com.ttg.web.service.OrganService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author huyangzou
 * @create 2020-11-27 15:40
 */
@Slf4j
@Service
public class OrganServiceImpl  extends ServiceImpl<OrganMapper, Organ> implements OrganService {

    @Override
    public Organ getOrganByOrgNo(Long orgNo) {
        LambdaQueryWrapper<Organ> wrapper = new LambdaQueryWrapper<Organ>();
        wrapper.select(Organ::getOrgNo);
        wrapper.eq(Organ::getOrgStatus, OrgStatusEnum.NORMAL.getValue());
        wrapper.eq(Organ::getOrgNo,orgNo);
        return super.getOne(wrapper);
    }

    @Override
    public Organ getOrganByOrgNoAndStatus(Long orgNo, OrgStatusEnum anEnum) {
        LambdaQueryWrapper<Organ> wrapper = new LambdaQueryWrapper<Organ>();
        wrapper.eq(Organ::getOrgNo, orgNo)
        .eq(Organ::getOrgStatus,anEnum.getValue());
        return getOne(wrapper);
    }

}
